#include <iostream>
#include <stack>
using namespace std;
class TreeNode{
public:
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int val){
        this->val = val;
    }
};

TreeNode* create(TreeNode *root){
    int val;
    cin>>val;
    if(val == 0)
        return NULL;
    root = new TreeNode(val);
    root->left = create(root->left);
    root->right = create(root->right);
    return root;
}

void inorderTraversal(TreeNode *root){
    stack<TreeNode*> stack;
    TreeNode *cur = root;
    while(cur != NULL || !stack.empty()){
        while(cur != NULL){
            stack.push(cur);
            cur = cur->left;
        }
        cur = stack.top();
        stack.pop();
        cout<<cur->val<<"\t";
        cur = cur->right;
    }
    cout<<endl;
}

